PROJECT_PATH=$(pwd)
originGoROOT=$(go env GOROOT)
go env -w GOPROXY="https://goproxy.cn,direct"
go install github.com/visualfc/gotools@latest
go install github.com/stamblerre/gocode@latest
originGoPATH=$(go env GOPATH)

if [ ! -d "/data/go230" ];then 
    mkdir -p /data/go230 
    mkdir -p /data/gopath230/src 
    mkdir -p /data/gopath230/bin 
    mkdir -p /data/gopath230/pkg 
    cd ${originGoROOT}
    cp -rf * /data/go230
    cd ${PROJECT_PATH}/contract-sdk-docker-go-ide
    mkdir -p /data/go230/src/chainmaker 
    cp -rf * /data/go230/src/chainmaker 
    cp $originGoPATH/bin/gocode /data/go230/bin 
    cp $originGoPATH/bin/gotools /data/go230/bin 
    cd /data/go230/src 
    rm -rf ../pkg/linux_amd64/chainmaker 
    rm -rf -v chainmaker/contract* 
    rm -rf -v chainmaker/.DS_Store
    rm -rf -v chainmaker/test 
    rm -rf -v chainmaker/.git* 
    rm -rf -v chainmaker/go.mod 
    rm -rf -v chainmaker/go.sum 
    rm -rf -v chainmaker/pb/proto/ 
    rm -rf -v chainmaker/pb/Makefile 
    rm -rf -v vendor    
fi 
if [ ! -d "/data/go230copy" ];then 
    mkdir -p /data/go230copy
    cd ${originGoROOT} 
    cp -rf * /data/go230copy 
    cd ${PROJECT_PATH}/contract-sdk-go
    mkdir -p /data/go230copy/src/chainmaker 
    cp -rf * /data/go230copy/src/chainmaker 
    cd /data/go230copy/src  
    rm -rf -v chainmaker/.git*  
    rm -rf -v chainmaker/demo/  
    rm -rf -v chainmaker/go.mod  
    rm -rf -v chainmaker/go.sum      
    rm -rf -v chainmaker/main.go  
    rm -rf -v chainmaker/Makefile  
    rm -rf -v chainmaker/build.sh  
    rm -rf -v chainmaker/pb/proto/  
    rm -rf -v vendor  
    sed -i "s/chainmaker.org\\/chainmaker\\/contract-sdk-go\\/v2/chainmaker/g" $(grep contract-sdk-go -rl /data/go230copy/src/chainmaker)
fi 
